home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / adx7mu1a / players.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-10  |  42.0 KB  |  1,218 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  4. Begin VB.Form MainBoard 
  5.    Appearance      =   0  'Flat
  6.    AutoRedraw      =   -1  'True
  7.    BackColor       =   &H00C0C0C0&
  8.    Caption         =   "Tic-Tac-Toe"
  9.    ClientHeight    =   6285
  10.    ClientLeft      =   60
  11.    ClientTop       =   630
  12.    ClientWidth     =   8175
  13.    FillColor       =   &H00FFFFFF&
  14.    BeginProperty Font 
  15.       Name            =   "Comic Sans MS"
  16.       Size            =   9.75
  17.       Charset         =   0
  18.       Weight          =   400
  19.       Underline       =   0   'False
  20.       Italic          =   0   'False
  21.       Strikethrough   =   0   'False
  22.    EndProperty
  23.    FontTransparent =   0   'False
  24.    ForeColor       =   &H00000040&
  25.    Icon            =   "players.frx":0000
  26.    LinkTopic       =   "Form1"
  27.    Picture         =   "players.frx":000C
  28.    ScaleHeight     =   419
  29.    ScaleMode       =   3  'Pixel
  30.    ScaleWidth      =   545
  31.    StartUpPosition =   2  'CenterScreen
  32.    Begin VB.TextBox chatbox 
  33.       BeginProperty Font 
  34.          Name            =   "Comic Sans MS"
  35.          Size            =   8.25
  36.          Charset         =   0
  37.          Weight          =   400
  38.          Underline       =   0   'False
  39.          Italic          =   0   'False
  40.          Strikethrough   =   0   'False
  41.       EndProperty
  42.       Height          =   330
  43.       Left            =   480
  44.       TabIndex        =   17
  45.       Text            =   "Type Message Here"
  46.       Top             =   5280
  47.       Visible         =   0   'False
  48.       Width           =   2535
  49.    End
  50.    Begin VB.CommandButton send_chat 
  51.       Caption         =   "Send"
  52.       Default         =   -1  'True
  53.       Height          =   375
  54.       Left            =   3120
  55.       TabIndex        =   3
  56.       Top             =   5280
  57.       Visible         =   0   'False
  58.       Width           =   975
  59.    End
  60.    Begin VB.Frame Frame1 
  61.       Caption         =   "Tic Tac Chat"
  62.       Height          =   2775
  63.       Left            =   360
  64.       TabIndex        =   15
  65.       Top             =   3000
  66.       Visible         =   0   'False
  67.       Width           =   3975
  68.       Begin RichTextLib.RichTextBox chatlabel 
  69.          Height          =   1815
  70.          Left            =   120
  71.          TabIndex        =   16
  72.          Top             =   360
  73.          Width           =   3735
  74.          _ExtentX        =   6588
  75.          _ExtentY        =   3201
  76.          _Version        =   393217
  77.          Enabled         =   -1  'True
  78.          TextRTF         =   $"players.frx":6AA8
  79.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  80.             Name            =   "Comic Sans MS"
  81.             Size            =   8.25
  82.             Charset         =   0
  83.             Weight          =   400
  84.             Underline       =   0   'False
  85.             Italic          =   0   'False
  86.             Strikethrough   =   0   'False
  87.          EndProperty
  88.       End
  89.    End
  90.    Begin VB.Timer Timer4 
  91.       Enabled         =   0   'False
  92.       Interval        =   5000
  93.       Left            =   5250
  94.       Top             =   510
  95.    End
  96.    Begin MSComctlLib.StatusBar StatusBar1 
  97.       Align           =   2  'Align Bottom
  98.       Height          =   315
  99.       Left            =   0
  100.       TabIndex        =   14
  101.       Top             =   5970
  102.       Width           =   8175
  103.       _ExtentX        =   14420
  104.       _ExtentY        =   556
  105.       Style           =   1
  106.       _Version        =   393216
  107.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  108.          NumPanels       =   1
  109.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  110.          EndProperty
  111.       EndProperty
  112.    End
  113.    Begin VB.CommandButton restart 
  114.       Caption         =   "Restart Game"
  115.       Enabled         =   0   'False
  116.       BeginProperty Font 
  117.          Name            =   "Arial"
  118.          Size            =   8.25
  119.          Charset         =   0
  120.          Weight          =   400
  121.          Underline       =   0   'False
  122.          Italic          =   0   'False
  123.          Strikethrough   =   0   'False
  124.       EndProperty
  125.       Height          =   450
  126.       Left            =   3150
  127.       TabIndex        =   2
  128.       Top             =   2235
  129.       Width           =   1245
  130.    End
  131.    Begin VB.Label Game_Over 
  132.       Alignment       =   2  'Center
  133.       AutoSize        =   -1  'True
  134.       BackColor       =   &H00C0C0C0&
  135.       BackStyle       =   0  'Transparent
  136.       BeginProperty Font 
  137.          Name            =   "Comic Sans MS"
  138.          Size            =   14.25
  139.          Charset         =   0
  140.          Weight          =   700
  141.          Underline       =   0   'False
  142.          Italic          =   -1  'True
  143.          Strikethrough   =   0   'False
  144.       EndProperty
  145.       ForeColor       =   &H000000FF&
  146.       Height          =   330
  147.       Left            =   6060
  148.       TabIndex        =   13
  149.       Top             =   5100
  150.       Width           =   135
  151.    End
  152.    Begin VB.Label Layer_A 
  153.       Caption         =   "Label9"
  154.       BeginProperty Font 
  155.          Name            =   "Arial"
  156.          Size            =   8.25
  157.          Charset         =   0
  158.          Weight          =   400
  159.          Underline       =   0   'False
  160.          Italic          =   0   'False
  161.          Strikethrough   =   0   'False
  162.       EndProperty
  163.       Height          =   525
  164.       Index           =   8
  165.       Left            =   6675
  166.       TabIndex        =   12
  167.       Top             =   4095
  168.       Width           =   555
  169.    End
  170.    Begin VB.Label Layer_A 
  171.       Caption         =   "Label9"
  172.       BeginProperty Font 
  173.          Name            =   "Arial"
  174.          Size            =   8.25
  175.          Charset         =   0
  176.          Weight          =   400
  177.          Underline       =   0   'False
  178.          Italic          =   0   'False
  179.          Strikethrough   =   0   'False
  180.       EndProperty
  181.       Height          =   525
  182.       Index           =   7
  183.       Left            =   5835
  184.       TabIndex        =   11
  185.       Top             =   4095
  186.       Width           =   555
  187.    End
  188.    Begin VB.Label Layer_A 
  189.       BackColor       =   &H00000000&
  190.       Caption         =   "Label9"
  191.       BeginProperty Font 
  192.          Name            =   "Arial"
  193.          Size            =   8.25
  194.          Charset         =   0
  195.          Weight          =   400
  196.          Underline       =   0   'False
  197.          Italic          =   0   'False
  198.          Strikethrough   =   0   'False
  199.       EndProperty
  200.       Height          =   525
  201.       Index           =   6
  202.       Left            =   4950
  203.       TabIndex        =   10
  204.       Top             =   4095
  205.       Width           =   555
  206.    End
  207.    Begin VB.Label Layer_A 
  208.       Caption         =   "Label9"
  209.       BeginProperty Font 
  210.          Name            =   "Arial"
  211.          Size            =   8.25
  212.          Charset         =   0
  213.          Weight          =   400
  214.          Underline       =   0   'False
  215.          Italic          =   0   'False
  216.          Strikethrough   =   0   'False
  217.       EndProperty
  218.       Height          =   525
  219.       Index           =   5
  220.       Left            =   6675
  221.       TabIndex        =   9
  222.       Top             =   3180
  223.       Width           =   555
  224.    End
  225.    Begin VB.Label Layer_A 
  226.       Caption         =   "Label9"
  227.       BeginProperty Font 
  228.          Name            =   "Arial"
  229.          Size            =   8.25
  230.          Charset         =   0
  231.          Weight          =   400
  232.          Underline       =   0   'False
  233.          Italic          =   0   'False
  234.          Strikethrough   =   0   'False
  235.       EndProperty
  236.       Height          =   525
  237.       Index           =   4
  238.       Left            =   5835
  239.       TabIndex        =   8
  240.       Top             =   3180
  241.       Width           =   555
  242.    End
  243.    Begin VB.Label Layer_A 
  244.       Caption         =   "Label9"
  245.       BeginProperty Font 
  246.          Name            =   "Arial"
  247.          Size            =   8.25
  248.          Charset         =   0
  249.          Weight          =   400
  250.          Underline       =   0   'False
  251.          Italic          =   0   'False
  252.          Strikethrough   =   0   'False
  253.       EndProperty
  254.       Height          =   525
  255.       Index           =   3
  256.       Left            =   4950
  257.       TabIndex        =   7
  258.       Top             =   3180
  259.       Width           =   555
  260.    End
  261.    Begin VB.Label Layer_A 
  262.       Caption         =   "Label9"
  263.       BeginProperty Font 
  264.          Name            =   "Arial"
  265.          Size            =   8.25
  266.          Charset         =   0
  267.          Weight          =   400
  268.          Underline       =   0   'False
  269.          Italic          =   0   'False
  270.          Strikethrough   =   0   'False
  271.       EndProperty
  272.       Height          =   525
  273.       Index           =   2
  274.       Left            =   6675
  275.       TabIndex        =   6
  276.       Top             =   2265
  277.       Width           =   555
  278.    End
  279.    Begin VB.Label Layer_A 
  280.       Appearance      =   0  'Flat
  281.       BackColor       =   &H80000005&
  282.       Caption         =   "Label9"
  283.       BeginProperty Font 
  284.          Name            =   "Arial"
  285.          Size            =   8.25
  286.          Charset         =   0
  287.          Weight          =   400
  288.          Underline       =   0   'False
  289.          Italic          =   0   'False
  290.          Strikethrough   =   0   'False
  291.       EndProperty
  292.       ForeColor       =   &H80000008&
  293.       Height          =   525
  294.       Index           =   1
  295.       Left            =   5835
  296.       TabIndex        =   5
  297.       Top             =   2265
  298.       Width           =   555
  299.    End
  300.    Begin VB.Label Layer_A 
  301.       BackStyle       =   0  'Transparent
  302.       Caption         =   "Label9"
  303.       BeginProperty Font 
  304.          Name            =   "Arial"
  305.          Size            =   8.25
  306.          Charset         =   0
  307.          Weight          =   400
  308.          Underline       =   0   'False
  309.          Italic          =   0   'False
  310.          Strikethrough   =   0   'False
  311.       EndProperty
  312.       ForeColor       =   &H000000C0&
  313.       Height          =   525
  314.       Index           =   0
  315.       Left            =   4950
  316.       MouseIcon       =   "players.frx":6B8E
  317.       MousePointer    =   2  'Cross
  318.       TabIndex        =   4
  319.       Top             =   2250
  320.       Width           =   555
  321.    End
  322.    Begin VB.Label playerdisplaylabel 
  323.       AutoSize        =   -1  'True
  324.       BackStyle       =   0  'Transparent
  325.       BeginProperty Font 
  326.          Name            =   "Comic Sans MS"
  327.          Size            =   9.75
  328.          Charset         =   0
  329.          Weight          =   700
  330.          Underline       =   0   'False
  331.          Italic          =   -1  'True
  332.          Strikethrough   =   0   'False
  333.       EndProperty
  334.       ForeColor       =   &H00FFFFFF&
  335.       Height          =   270
  336.       Left            =   345
  337.       TabIndex        =   1
  338.       Top             =   360
  339.       Width           =   90
  340.    End
  341.    Begin VB.Label Out_Box 
  342.       Alignment       =   2  'Center
  343.       AutoSize        =   -1  'True
  344.       BackColor       =   &H00C0C0C0&
  345.       BackStyle       =   0  'Transparent
  346.       BeginProperty Font 
  347.          Name            =   "Comic Sans MS"
  348.          Size            =   18
  349.          Charset         =   0
  350.          Weight          =   700
  351.          Underline       =   0   'False
  352.          Italic          =   0   'False
  353.          Strikethrough   =   0   'False
  354.       EndProperty
  355.       ForeColor       =   &H00FFFFFF&
  356.       Height          =   525
  357.       Left            =   6030
  358.       TabIndex        =   0
  359.       Top             =   1320
  360.       Width           =   150
  361.    End
  362.    Begin VB.Menu Multiplay 
  363.       Caption         =   "&MultiPlayer"
  364.       Begin VB.Menu hostagame 
  365.          Caption         =   "&Host a Game"
  366.       End
  367.       Begin VB.Menu joinagame 
  368.          Caption         =   "&Join a Game"
  369.       End
  370.       Begin VB.Menu mnudisconnect 
  371.          Caption         =   "&Disconnect"
  372.       End
  373.    End
  374.    Begin VB.Menu options 
  375.       Caption         =   "&Options"
  376.       Begin VB.Menu mnuchat 
  377.          Caption         =   "&Chat On"
  378.          Enabled         =   0   'False
  379.       End
  380.       Begin VB.Menu xxxxxxx 
  381.          Caption         =   "Who's First"
  382.          Begin VB.Menu x 
  383.             Caption         =   "X's"
  384.          End
  385.          Begin VB.Menu o 
  386.             Caption         =   "O's"
  387.          End
  388.       End
  389.    End
  390.    Begin VB.Menu game 
  391.       Caption         =   "&Game"
  392.       Begin VB.Menu newgame 
  393.          Caption         =   "&New Game"
  394.       End
  395.       Begin VB.Menu exit 
  396.          Caption         =   "E&xit"
  397.       End
  398.    End
  399. Attribute VB_Name = "MainBoard"
  400. Attribute VB_GlobalNameSpace = False
  401. Attribute VB_Creatable = False
  402. Attribute VB_PredeclaredId = True
  403. Attribute VB_Exposed = False
  404. '*************************************************************
  405. '*   Multiplayer Tic Tac Toe                                 *
  406. '*      Mike Altmanshofer-Masher2@ibm.net                    *
  407. '*         Distribute Freely                                 *
  408. '*           Please Leave this Header description intact.    *
  409. '*          Created 06-01-99 Last Modified 10-10-99(DX7)     *
  410. '*                                                           *
  411. '*                                                           *
  412. '*                                                           *
  413. '*************************************************************
  414. Option Explicit
  415. Dim a(9) As Integer
  416. Dim Player_A(9) As Integer 'Initialize X array
  417. Dim Computer_A(9) As Integer 'Initialize O array
  418. Dim Test_Result(8) As Integer
  419. Dim Win(3) As Integer ' Spots won to marked
  420. Dim m, Token, first_turn, temp1 As Integer
  421. Dim Temp As Boolean  'check whether player won
  422. Dim Sq_Left, n1, mark As Integer
  423. Dim tr As String 'string passed on win to mark routine
  424. Dim Begin As Boolean 'continue winning spots flashing
  425. Dim sw As Boolean  'Sets whether X or O starts game
  426. Public Sub Initialize()
  427. ' select who's turn
  428. If usermode = "host" And multiplayermode = True Then
  429. ' set o or x first
  430.     If sw = True Then
  431.         MyTurn = True
  432.     Else
  433.         MyTurn = False
  434.     End If
  435. End If
  436. If multiplayermode = False Then
  437.    MyTurn = True
  438. End If
  439. Begin = False   ' cancel marking routine
  440. score = score + 1 'adds one to gamecount
  441. If multiplayermode = True Then
  442. If usermode = "client" And sw = True Then
  443.        MyTurn = False
  444. ElseIf usermode = "client" And sw = False Then
  445.        MyTurn = True
  446. End If
  447. End If
  448. 'Start SW true mode**********************************
  449.       'initialize game settings
  450. If sw = True Then
  451.     StatusBar1.SimpleText = "New Game Initialized" & "           X's Turn"
  452.     Debug.Print "Turn Status " & MyTurn
  453.     Debug.Print "SW Value is " & sw
  454.     Dim u As Integer
  455.     u = 0
  456.     Sq_Left = 9
  457.     Token = 10
  458.         For u = 0 To 8
  459.             Layer_A(u).MousePointer = vbCustom
  460.             'select starting icon and characteristics****************************
  461.                 If usermode = "host" Then
  462.                     Layer_A(u).MouseIcon = LoadResPicture("x", vbResIcon)
  463.                 Else
  464.                     Layer_A(u).MouseIcon = LoadResPicture("nyt", vbResIcon)
  465.                 End If
  466.             Layer_A(u).FontSize = 28
  467.             Layer_A(u).FontBold = True
  468.             Layer_A(u).Caption = ""
  469.             Layer_A(u).BackStyle = 0
  470.             Layer_A(u).Alignment = 2
  471.             Player_A(u) = 0
  472.             Computer_A(u) = 0
  473.             Layer_A(u).Enabled = True
  474.         Next u
  475.     'update statusbar and display routine******************************
  476.     If usermode = "host" And multiplayermode = True Then
  477.         StatusBar1.SimpleText = "New Game Initialized          " & profilename & "'s Turn"
  478.         Out_Box.Caption = profilename & "'s Turn."
  479.     End If
  480.     If usermode = "client" And multiplayermode = True Then
  481.         StatusBar1.SimpleText = "New Game Initialized          " & opponentsname & "'s Turn"
  482.         Out_Box.Caption = opponentsname & "'s Turn."
  483.     End If
  484.     If multiplayermode = False Then
  485.         Out_Box.Caption = "X Goes First"
  486.     End If
  487. End If
  488. 'End sw true*********************************************
  489. 'set starting icon*****************
  490. If sw = False Then
  491.     StatusBar1.SimpleText = "New Game Initialized" & "           O's Turn"
  492.     Debug.Print "Turn Status " & MyTurn
  493.     Debug.Print "SW Value is " & sw
  494.     u = 0
  495.     Sq_Left = 9
  496.     Token = 10
  497.         For u = 0 To 8
  498.             Layer_A(u).MousePointer = vbCustom
  499.                 If usermode = "host" And multiplayermode = True Then
  500.                     Layer_A(u).MouseIcon = LoadResPicture("nyt", vbResIcon)
  501.                 Else
  502.                     Layer_A(u).MouseIcon = LoadResPicture("o", vbResIcon)
  503.                 End If
  504.             Layer_A(u).FontSize = 28
  505.             Layer_A(u).FontBold = True
  506.             Layer_A(u).Caption = ""
  507.             Layer_A(u).BackStyle = 0
  508.             Layer_A(u).Alignment = 2
  509.             Player_A(u) = 0
  510.             Computer_A(u) = 0
  511.             Layer_A(u).Enabled = True
  512.         Next u
  513.     Temp = False  'initiate no win
  514.     'Update Statusbar and outbox display********************8
  515.         If usermode = "client" And multiplayermode = True Then
  516.             StatusBar1.SimpleText = "New Game Initialized          " & profilename & "'s Turn"
  517.             Out_Box.Caption = profilename & " 's Turn."
  518.         End If
  519.         If usermode = "host" And multiplayermode = True Then
  520.             StatusBar1.SimpleText = "New Game Initialized          " & opponentsname & "'s Turn"
  521.             Out_Box.Caption = opponentsname & " 's Turn."
  522.         End If
  523.         If multiplayermode = False Then
  524.             Out_Box.Caption = "O Goes First"
  525.         End If
  526. End If
  527. 'End sw false*********************************************
  528. Debug.Print "Ran Initialization Myturn status is " & MyTurn
  529. Game_Over.Caption = "New Game"
  530. End Sub
  531. Private Sub exit_Click()
  532. If onconnect = True Then 'checks for connection
  533. On Error GoTo NoDx 'error to handle dxplay not initialized
  534. Dim dpmsg As DirectPlayMessage
  535. Set dpmsg = dxplay.CreateMessage
  536. Call dpmsg.WriteLong(MSG_STOP) 'Sends player quit message to other player
  537. Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, dpmsg)
  538. Call CloseDownDPlay 'shuts down dxplay
  539. End If
  540. Unload Connect 'unloads connect form if connect frees memory
  541. Unload MainBoard 'unloads board before ending to free memory
  542. NoDx:
  543.     MsgBox "Could not stop DXPlay.", vbOKOnly, "System"
  544.     End
  545. End Sub
  546. Private Sub Form_Load()
  547. On Error GoTo NoLoad 'Handles errors in case form won't load
  548. MainBoard.Icon = LoadResPicture("ictac", vbResIcon) 'form icon
  549. restart.Visible = False 'restart button not seen on single player or client mode
  550. mnudisconnect.Enabled = False 'set menu item to no connect state
  551. onconnect = False 'Sets connection status to false by default
  552. sw = True 'set starting Player to x
  553. x.Checked = True 'set menuitem X to x checked
  554. multiplayermode = False 'initiate mode to false
  555. Call deinitialize  'disables all squares until gamemode and multiplayer mode is decided
  556. score = 0  'sets game count to 0
  557. Exit Sub
  558. NoLoad:
  559. MsgBox "Could Not Load Form", vbOKOnly, "Quitting"
  560. End Sub
  561. Private Sub deinitialize()
  562. 'Disables all squares until game selection is made
  563. Dim m As Integer
  564.     For m = 0 To 8
  565.         Layer_A(m).MousePointer = vbCustom
  566.             If sw = True Then 'sets mouse pointer to x for x first
  567.                 Layer_A(m).MouseIcon = LoadResPicture("x", vbResIcon)
  568.             Else 'sets mouse pointer to O for O first
  569.                 Layer_A(m).MouseIcon = LoadResPicture("o", vbResIcon)
  570.             End If
  571.         Layer_A(m).FontSize = 28
  572.         Layer_A(m).FontBold = True
  573.         Layer_A(m).Caption = ""
  574.         Layer_A(m).BackStyle = 0
  575.         Layer_A(m).Alignment = 2
  576.         Layer_A(m).Enabled = False
  577.     Next m
  578. 'Update Status Bar
  579. StatusBar1.SimpleText = "Select Game- New Game or Multiplayer option to start game"
  580. Out_Box.Caption = "Start New Game."
  581. End Sub
  582. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  583. If onconnect = True Then
  584.     On Error GoTo NoDx
  585.     Dim dpmsg As DirectPlayMessage
  586.     Set dpmsg = dxplay.CreateMessage
  587.     Call dpmsg.WriteLong(MSG_STOP)
  588.     Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, dpmsg)
  589.     Call CloseDownDPlay
  590. End If
  591. Unload Connect
  592. Unload MainBoard
  593. NoDx:
  594.     MsgBox "Could not stop DXPlay.", vbOKOnly, "System"
  595.     End
  596. End Sub
  597. Private Sub hostagame_Click()
  598. usermode = "host" 'Sets usermode to host
  599. Connect.Show 'starts connect form
  600. MainBoard.Enabled = False 'disable form so user cannot select while connect form is up
  601. hostagame.Enabled = False 'disables menu host button.
  602. joinagame.Enabled = False ' disables menu join button
  603. multiplayermode = True 'sets multiplayer to true
  604. End Sub
  605. Private Sub joinagame_Click()
  606. usermode = "client" 'Sets usermode to client
  607. Connect.Show
  608. MainBoard.Enabled = False
  609. multiplayermode = True
  610. End Sub
  611. Private Sub Layer_A_Click(Index As Integer)
  612. playerdisplaylabel.Caption = ""
  613. 'Used For single player board selection or multiplayer your turn selection
  614. Debug.Print "Layer A Click Turn Status " & MyTurn
  615. Debug.Print "Layer A Multiplayer Mode Status " & multiplayermode
  616. If multiplayermode = True And MyTurn = False Then  'Easy way to exit if not your turn
  617.     Exit Sub
  618. End If
  619. If Sq_Left Mod 2 = 1 Then 'check remainder of squares left divided by 2
  620.         If sw = True Then ' sets who goes first X or O
  621.             Layer_A(Index).Caption = "X"
  622.         Else
  623.             Layer_A(Index).Caption = "O"
  624.         End If
  625.     Layer_A(Index).Enabled = False 'Sets selected square to not available
  626.     Player_A(Index) = 1
  627.     Computer_A(Index) = -Token
  628.     LoadPlayer
  629.         If multiplayermode = True And MyTurn = True Then 'checks for multiplayer and turn status
  630.             'This routine below packs message to send
  631.             'to other player to select the square chosen.
  632.             Dim dpmsg As DirectPlayMessage 'alot direct playmessage
  633.             Set dpmsg = dxplay.CreateMessage 'set and create the message
  634.             Call dpmsg.WriteLong(MSG_MOVE) 'pack message structure and identify type
  635.             Call dpmsg.WriteByte(Index) 'Packs case selection number to msgtype.
  636.             'This sends the pack message structure
  637.             Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, dpmsg)
  638.         End If
  639.         If multiplayermode = True Then 'Sets routines to not your turn on multiplayer
  640.             Dim Y As Integer
  641.             Y = 0
  642.                 For Y = 0 To 8
  643.                     Layer_A(Y).MouseIcon = LoadResPicture("nyt", vbResIcon)
  644.                 Next Y
  645.             'Update Status displays
  646.             StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & opponentsname & "'s Turn"
  647.             Out_Box.Caption = opponentsname & "'s Turn."
  648.         End If
  649.     'Everything below until mod else statement is single player
  650.         If multiplayermode = False Then 'Sets X or O turn status on single player
  651.             If sw = True Then
  652.                 StatusBar1.SimpleText = "New Game Initialized          O's Turn"
  653.             Else
  654.                 StatusBar1.SimpleText = "New Game Initialized         X's Turn"
  655.             End If
  656.         If sw = True Then
  657.             Y = 0
  658.                 For Y = 0 To 8
  659.                     Layer_A(Y).MouseIcon = LoadResPicture("o", vbResIcon)
  660.                 Next Y
  661.         Else
  662.             Y = 0
  663.                 For Y = 0 To 8
  664.                     Layer_A(Y).MouseIcon = LoadResPicture("x", vbResIcon)
  665.                 Next Y
  666.         End If
  667.         If sw = True Then
  668.             Out_Box.Caption = "O's Turn"
  669.         Else
  670.             Out_Box.Caption = "X's Turn"
  671.         End If
  672.     End If
  673.     'Mod else*********************************
  674.         If sw = True Then
  675.             Layer_A(Index).Caption = "O"
  676.         Else
  677.             Layer_A(Index).Caption = "X"
  678.         End If
  679.     Layer_A(Index).Enabled = False
  680.     Player_A(Index) = -Token
  681.     Computer_A(Index) = 1
  682.         If multiplayermode = True Then
  683.             StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & opponentsname & "'s Turn"
  684.                 For Y = 0 To 8
  685.                     Layer_A(Y).MouseIcon = LoadResPicture("nyt", vbResIcon)
  686.                 Next Y
  687.             Out_Box.Caption = opponentsname & "'s Turn."
  688.         End If
  689.         If multiplayermode = False Then
  690.             If sw = True Then
  691.                 StatusBar1.SimpleText = "New Game Initialized          X's Turn"
  692.             Else
  693.                 StatusBar1.SimpleText = "New Game Initialized          O's Turn"
  694.             End If
  695.         If sw = True Then
  696.             Y = 0
  697.                 For Y = 0 To 8
  698.                     Layer_A(Y).MouseIcon = LoadResPicture("x", vbResIcon)
  699.                 Next Y
  700.             Out_Box.Caption = "X's Turn"
  701.         Else
  702.             Y = 0
  703.                 For Y = 0 To 8
  704.                     Layer_A(Y).MouseIcon = LoadResPicture("o", vbResIcon)
  705.                 Next Y
  706.             Out_Box.Caption = "O's Turn"
  707.         End If
  708.     End If
  709.     LoadComputer
  710.         If multiplayermode = True And MyTurn = True Then
  711.           'Same as above packs message and sends move to other player
  712.             Dim dpmsg2 As DirectPlayMessage
  713.             Set dpmsg2 = dxplay.CreateMessage
  714.             Call dpmsg2.WriteLong(MSG_MOVE)
  715.             Call dpmsg2.WriteByte(Index)
  716.             Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, dpmsg2)
  717.         End If
  718. End If
  719. Sq_Left = Sq_Left - 1
  720. EvalNextMove
  721. MyTurn = False
  722. End Sub
  723. Public Function layer_A_online(Index As Integer)
  724. playerdisplaylabel.Caption = ""
  725. 'This routine is called to mark sqares when remote computer
  726. 'sends a move made command.
  727. 'Same as above with some redundant routines removed
  728. If Sq_Left Mod 2 = 1 Then
  729.     If sw = True Then
  730.         Layer_A(Index).Caption = "X"
  731.     Else
  732.         Layer_A(Index).Caption = "O"
  733.     End If
  734.     Layer_A(Index).Enabled = False
  735.     Player_A(Index) = 1
  736.     Computer_A(Index) = -Token
  737.         If multiplayermode = True Then
  738.             If sw = True Then
  739.                 StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & profilename & "'s Turn"
  740.                 Out_Box.Caption = profilename & "'s Turn."
  741.                 Dim Y As Integer
  742.                     For Y = 0 To 8
  743.                         Layer_A(Y).MouseIcon = LoadResPicture("o", vbResIcon)
  744.                     Next Y
  745.             Else
  746.                 StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & profilename & "'s Turn"
  747.                 Out_Box.Caption = profilename & "'s Turn."
  748.                 Y = 0
  749.                     For Y = 0 To 8
  750.                         Layer_A(Y).MouseIcon = LoadResPicture("x", vbResIcon)
  751.                     Next Y
  752.             End If
  753.         End If
  754.         If multiplayermode = False Then
  755.             If sw = True Then
  756.                 Y = 0
  757.                     For Y = 0 To 8
  758.                         Layer_A(Y).MouseIcon = LoadResPicture("o", vbResIcon)
  759.                         Out_Box.Caption = "O's Turn"
  760.                     Next Y
  761.             Else
  762.             Y = 0
  763.                 For Y = 0 To 8
  764.                     Layer_A(Y).MouseIcon = LoadResPicture("x", vbResIcon)
  765.                     Out_Box.Caption = "X's Turn"
  766.             Next Y
  767.             End If
  768.         End If
  769.     LoadPlayer
  770.     If sw = True Then
  771.         Layer_A(Index).Caption = "O"
  772.     Else
  773.         Layer_A(Index).Caption = "X"
  774.     End If
  775.     Layer_A(Index).Enabled = False
  776.     Player_A(Index) = -Token
  777.     Computer_A(Index) = 1
  778.     If multiplayermode = True Then
  779.         If sw = True Then
  780.             StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & profilename & "'s Turn"
  781.             Out_Box.Caption = profilename & "'s Turn."
  782.             Y = 0
  783.                 For Y = 0 To 8
  784.                     Layer_A(Y).MouseIcon = LoadResPicture("x", vbResIcon)
  785.                 Next Y
  786.         Else
  787.             StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & profilename & "'s Turn"
  788.             Out_Box.Caption = profilename & "'s Turn."
  789.             Y = 0
  790.                 For Y = 0 To 8
  791.                     Layer_A(Y).MouseIcon = LoadResPicture("o", vbResIcon)
  792.             Next Y
  793.         End If
  794.     End If
  795.     If multiplayermode = False Then
  796.         If sw = True Then
  797.             StatusBar1.SimpleText = "New Game Initialized          X's Turn"
  798.         Else
  799.             StatusBar1.SimpleText = "New Game Initialized          O's Turn"
  800.     End If
  801.     If sw = True Then
  802.         Y = 0
  803.             For Y = 0 To 8
  804.                 Layer_A(Y).MouseIcon = LoadResPicture("x", vbResIcon)
  805.             Next Y
  806.             Out_Box.Caption = "X's Turn"
  807.     Else
  808.         Y = 0
  809.             For Y = 0 To 8
  810.                 Layer_A(Y).MouseIcon = LoadResPicture("o", vbResIcon)
  811.             Next Y
  812.         Out_Box.Caption = "O's Turn"
  813.     End If
  814.     End If
  815.         LoadComputer
  816. End If
  817. Sq_Left = Sq_Left - 1
  818. EvalNextMove
  819. End Function
  820. Private Sub scan_3() '*****************************************
  821. Dim r As Integer
  822. For r = 0 To 7
  823.     If Test_Result(r) = 3 Then
  824.     Temp = True
  825.     End If
  826. Next r
  827. End Sub
  828. Private Sub EvalNextMove() '***********************************
  829. scan_3
  830. Debug.Print "Squares Left Value on Evaluate Next Move " & Sq_Left
  831. Debug.Print "Boolean Temp Value on Evaluate " & Temp
  832. Debug.Print "Token Value on Eval. " & Token
  833. If Temp = True Then
  834.     If Sq_Left Mod 2 = 0 Then 'Makes win or lose calls Turn checking is made later
  835.         Player_Wins 'call player wins routine
  836.     Else
  837.         Computer_Wins 'calls computer rountine
  838.     End If
  839. End If
  840. Temp = False
  841. If Sq_Left <= 0 Then
  842.     Cats_Game
  843.     Begin = False 'Turns off mark routine
  844.         If multiplayermode = True And usermode = "host" Then 'sets turn to true
  845.             MyTurn = True
  846.             Debug.Print "Set myturn to true on win"
  847.         End If
  848. End If
  849. first_turn = 1
  850. End Sub
  851. Private Sub Computer_Wins()
  852. Dim s As Integer
  853. For s = 0 To 8
  854.     Layer_A(s).Enabled = False
  855. Next s
  856. Begin = True
  857. If multiplayermode = True And usermode = "host" Then
  858.     If sw = True Then 'Checks for Whos Turn and update Host or client
  859.         Out_Box.Caption = opponentsname & " Won!"
  860.         opponentsscore = opponentsscore + 1
  861.     Else
  862.         Out_Box.Caption = profilename & " Won!"
  863.         profilenamescore = profilenamescore + 1
  864.     End If
  865. End If
  866. If multiplayermode = True And usermode = "client" Then
  867.     If sw = True Then
  868.         Out_Box.Caption = profilename & " Won!"
  869.         profilenamescore = profilenamescore + 1
  870.     Else
  871.         Out_Box.Caption = opponentsname & " Won!"
  872.         opponentsscore = opponentsscore + 1
  873.     End If
  874. End If
  875. If multiplayermode = False Then 'Single Player updating
  876.     If sw = True Then
  877.         Out_Box.Caption = "O Won!!!!"
  878.     Else
  879.         Out_Box.Caption = "X Won!!!!!"
  880.     End If
  881. End If
  882. Game_Over.Caption = "Game Over"
  883. 'Shows Resart Option if Host
  884. If multiplayermode = True And usermode = "host" Then
  885.     restart.Visible = True
  886.     restart.Enabled = True
  887. End If
  888. Timer4.Enabled = True 'Sets timer to time mark routine
  889. If sw = True Then 'Checks Whos turn sends string to mark
  890.      Call Mark_Win("O")
  891.      Call Mark_Win("X")
  892. End If
  893. End Sub
  894. Private Sub Player_Wins()
  895. 'See computer wins for details
  896. Dim a As Integer
  897.     For a = 0 To 8
  898.         Layer_A(a).Enabled = False
  899.     Next a
  900. Begin = True
  901. If multiplayermode = True And usermode = "host" Then
  902.     If sw = True Then
  903.         profilenamescore = profilenamescore + 1
  904.         Out_Box.Caption = profilename & " Won!"
  905.     Else
  906.         opponentsscore = opponentsscore + 1
  907.         Out_Box.Caption = opponentsname & " Won!"
  908.     End If
  909. End If
  910. If multiplayermode = True And usermode = "client" Then
  911.     If sw = True Then
  912.         opponentsscore = opponentsscore + 1
  913.         Out_Box.Caption = opponentsname & " Won!"
  914.     Else
  915.         profilenamescore = profilenamescore + 1
  916.         Out_Box.Caption = profilename & " Won!"
  917.     End If
  918. End If
  919. If multiplayermode = False Then
  920.     If sw = True Then
  921.         Out_Box.Caption = "X Won!!!!"
  922.     Else
  923.         Out_Box.Caption = "O Won!!!!!"
  924.     End If
  925. End If
  926. Game_Over.Caption = "Game Over"
  927. If multiplayermode = True And usermode = "host" Then
  928.     restart.Visible = True
  929.     restart.Enabled = True
  930. End If
  931. Timer4.Enabled = True
  932. If sw = True Then
  933.     Call Mark_Win("X")
  934.     Call Mark_Win("O")
  935. End If
  936. End Sub
  937. Private Sub Mark_Win(tr As String) 'Marks winning squares
  938. Dim PauseTime, start, Finish, TotalTime
  939. While Begin = True
  940.     PauseTime = 0.3  ' Set duration.
  941.     start = Timer   ' Set start time.
  942.         Do While Timer < start + PauseTime And Begin = True
  943.             For n1 = 0 To 2
  944.                 mark = Win(n1)
  945.                 Layer_A(mark).Caption = tr
  946.                 Layer_A(mark).FontBold = False
  947.             Next n1
  948.             DoEvents    ' Yield to other processes.
  949.         Loop
  950.     start = Timer   ' Set start time.
  951.         Do While Timer < start + PauseTime And Begin = True
  952.             For n1 = 0 To 2
  953.                 mark = Win(n1)
  954.                 Layer_A(mark).FontBold = True
  955.                 Layer_A(mark).Caption = tr
  956.             Next n1
  957.             DoEvents    ' Yield to other processes.
  958.         Loop
  959. End Sub
  960. Private Sub test() 'Tests conditions for the win
  961. Dim n, k, sample As Integer
  962.     sample = 0
  963.     For n = 0 To 2
  964.         Test_Result(sample) = a(3 * n) + a(3 * n + 1) + a(3 * n + 2)
  965.         If Test_Result(sample) = 3 Then
  966.             Win(0) = 3 * n
  967.             Win(1) = 3 * n + 1
  968.             Win(2) = 3 * n + 2
  969.         End If
  970.         sample = sample + 1
  971.     Next n
  972.     For n = 0 To 2
  973.         Test_Result(sample) = a(n) + a(n + 3) + a(n + 6)
  974.         If Test_Result(sample) = 3 Then
  975.             Win(0) = n
  976.             Win(1) = n + 3
  977.             Win(2) = n + 6
  978.         End If
  979.         sample = sample + 1
  980.     Next n
  981.     Test_Result(sample) = a(0) + a(4) + a(8)
  982.         If Test_Result(sample) = 3 Then
  983.             Win(0) = 0
  984.             Win(1) = 4
  985.             Win(2) = 8
  986.         End If
  987.     sample = sample + 1
  988.     Test_Result(sample) = a(6) + a(4) + a(2)
  989.         If Test_Result(sample) = 3 Then
  990.             Win(0) = 6
  991.             Win(1) = 4
  992.             Win(2) = 2
  993.         End If
  994.     sample = sample + 1
  995. End Sub
  996. Private Sub LoadPlayer()
  997. Dim e As Integer
  998. For e = 0 To 8
  999.     a(e) = Player_A(e)
  1000. Next e
  1001. End Sub
  1002. Private Sub LoadComputer()
  1003. Dim w As Integer
  1004. For w = 0 To 8
  1005.     a(w) = Computer_A(w)
  1006. Next w
  1007. End Sub
  1008. Private Sub Cats_Game() 'Cats Game display routine
  1009. GameUnderway = False
  1010. Dim z As Integer
  1011. For z = 0 To 8
  1012.     Layer_A(z).Enabled = False
  1013. Next z
  1014. Out_Box.Caption = "Cat's Game!"
  1015. Game_Over.Caption = "Game Over"
  1016. If multiplayermode = True And usermode = "host" Then
  1017.     restart.Visible = True
  1018.     restart.Enabled = True
  1019. End If
  1020. End Sub
  1021. Private Sub mnuchat_Click() 'Menu button for chatbox routine
  1022. On Error GoTo NoChat 'error handler in case chat initialization problem.
  1023. If mnuchat.Checked = True Then
  1024.     Frame1.Visible = False
  1025.     chatlabel.Visible = False
  1026.     send_chat.Visible = False
  1027.     chatbox.Visible = False
  1028.     mnuchat.Checked = False
  1029.     'Packs and sends DXplay message to switch chat on off
  1030.     Dim chaton As DirectPlayMessage
  1031.     Set chaton = dxplay.CreateMessage
  1032.     Call chaton.WriteLong(MSG_CHAT_ON)
  1033.     Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, chaton)
  1034.     Frame1.Visible = True
  1035.     chatlabel.Visible = True
  1036.     send_chat.Visible = True
  1037.     chatbox.Visible = True
  1038.     mnuchat.Checked = True
  1039.     chatbox.Visible = True
  1040.     chatbox.SetFocus
  1041.      'Packs and sends DXplay message to switch chat on off
  1042.     Dim chaton2 As DirectPlayMessage
  1043.     Set chaton2 = dxplay.CreateMessage
  1044.     Call chaton2.WriteLong(MSG_CHAT_ON)
  1045.     Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, chaton2)
  1046. End If
  1047. Exit Sub
  1048. NoChat:
  1049.     MsgBox "Could Not Start Chat", vbOKOnly, "Oops"
  1050.     Exit Sub
  1051. End Sub
  1052. Public Function chatswitch() 'Menu button for incoming online Chatbox routine
  1053. On Error GoTo NoChat
  1054. If mnuchat.Checked = True Then
  1055.      Frame1.Visible = False
  1056.     chatlabel.Visible = False
  1057.     send_chat.Visible = False
  1058.     chatbox.Visible = False
  1059.     mnuchat.Checked = False
  1060.    Frame1.Visible = True
  1061.     chatlabel.Visible = True
  1062.     send_chat.Visible = True
  1063.     chatbox.Visible = True
  1064.     mnuchat.Checked = True
  1065.     chatbox.Visible = True
  1066.     chatbox.SetFocus
  1067. End If
  1068. Exit Function
  1069. NoChat:
  1070.     MsgBox "Could Not Start Chat", vbOKOnly, "Oops"
  1071.     Exit Function
  1072. End Function
  1073. Private Sub mnudisconnect_Click() 'Disconnects and sends disconnect message
  1074. mnudisconnect.Enabled = False
  1075. newgame.Enabled = True
  1076. hostagame.Enabled = True
  1077. joinagame.Enabled = True
  1078. multiplayermode = False
  1079. usermode = "host"
  1080. 'Sends player has left message to other players
  1081. Dim dpmsg As DirectPlayMessage
  1082. Set dpmsg = dxplay.CreateMessage
  1083. Call dpmsg.WriteLong(MSG_STOP)
  1084. Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, dpmsg)
  1085. Call CloseDownDPlay
  1086. Unload Connect
  1087. onconnect = False
  1088. End Sub
  1089. Private Sub newgame_Click() 'starts new game single or multiplayer
  1090. On Error GoTo NoGame
  1091. If usermode = "client" And multiplayermode = True Then
  1092.     MsgBox "Only the host can restart the game.", vbOKOnly, "Tic Tac Oops"
  1093.     Exit Sub
  1094. End If
  1095. If multiplayermode = False Then
  1096.     usermode = "host"
  1097.     Call Initialize
  1098.     Call restart_Click 'call restart routine for multiplayer
  1099. End If
  1100. Exit Sub
  1101. NoGame:
  1102.     MsgBox "Could Not Start Game.", vbOKOnly, "Oops"
  1103.     Exit Sub
  1104. End Sub
  1105. Public Sub o_Click() 'sets menu item whos first o
  1106. If GameUnderway = True Then
  1107. MsgBox "You cannot chang this option while a game is in play", vbOKOnly, "Tic Tac Oops"
  1108. Exit Sub
  1109. End If
  1110. If o.Checked = True Then
  1111.     sw = False
  1112.     Exit Sub
  1113.     o.Checked = True
  1114.     x.Checked = False
  1115.     sw = False
  1116. End If
  1117. If multiplayermode = True Then
  1118. 'Sends who goes first message.
  1119.    Dim dpmsg As DirectPlayMessage
  1120. Set dpmsg = dxplay.CreateMessage
  1121.         Call dpmsg.WriteLong(MSG_XORO)
  1122.         Call dpmsg.WriteByte(2)
  1123.         Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, _
  1124.                 dpmsg)
  1125. End If
  1126. Debug.Print "menu X or O clicked sw is " & sw
  1127. End Sub
  1128. Public Sub restart_Click() 'Restarts Game and updates scores
  1129. GameUnderway = True
  1130. multiplayermode = True
  1131. If usermode = "host" Then
  1132. Dim dpmsg As DirectPlayMessage
  1133. Set dpmsg = dxplay.CreateMessage
  1134.         Call dpmsg.WriteLong(MSG_RESTART)
  1135.         Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, _
  1136.                 dpmsg)
  1137. End If
  1138. Call Initialize
  1139. If usermode = "host" Then
  1140.     If sw = True Then
  1141.         MyTurn = True
  1142.         StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & profilename & "'s Turn"
  1143.         playerdisplaylabel.Caption = profilename & "'s Turn."
  1144.     Else
  1145.         
  1146.         MyTurn = False
  1147.         StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & opponentsname & "'s Turn"
  1148.         playerdisplaylabel.Caption = opponentsname & "'s Turn."
  1149.     End If
  1150. End If
  1151. If usermode = "client" Then
  1152.     If sw = True Then
  1153.         MyTurn = False
  1154.         StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & opponentsname & "'s Turn"
  1155.         playerdisplaylabel.Caption = opponentsname & "'s Turn."
  1156.     Else
  1157.         MyTurn = True
  1158.         StatusBar1.SimpleText = "Game count is " & score & "    " & opponentsname & ":" & opponentsscore & " | " & profilename & ":" & profilenamescore & "           " & profilename & "'s Turn"
  1159.         playerdisplaylabel.Caption = profilename & "'s Turn."
  1160.     End If
  1161. End If
  1162. restart.Visible = False
  1163. End Sub
  1164. Private Sub send_chat_Click()
  1165. 'handles chat boxes
  1166. Const chatlen = 5 + MChatString
  1167. Dim msgdata(chatlen) As Byte
  1168. Dim x As Integer
  1169. 'packs and sends chat box information
  1170. Dim cmsg As DirectPlayMessage
  1171. Set cmsg = dxplay.CreateMessage
  1172. Call cmsg.WriteLong(MSG_CHAT)
  1173. Call cmsg.WriteString(chatbox.Text)
  1174. Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, cmsg)
  1175. If chatlabel.Text = "" Then
  1176.     chatlabel.Text = profilename & ": " & chatbox.Text
  1177.       Else
  1178.     chatlabel.Text = chatlabel.Text & vbCrLf & profilename & ": " & chatbox.Text
  1179. End If
  1180. chatbox.Text = ""
  1181. End Sub
  1182. Private Sub Timer4_Timer()
  1183. GameUnderway = False
  1184. 'sets begin to false to stop letters from flashing.
  1185. 'Updates score and status bar.
  1186. Begin = False
  1187. If usermode = "host" And multiplayermode = True Then
  1188.     StatusBar1.SimpleText = "Select Restart Game.  " & "Game #" & score & "      " & profilename & ":" & profilenamescore & " " & opponentsname & ":" & opponentsscore
  1189.     MyTurn = True
  1190. ElseIf usermode = "client" And multiplayermode = True Then
  1191.     StatusBar1.SimpleText = "Waiting on Host To Restart.   " & "Game #" & score & "      " & profilename & ":" & profilenamescore & " " & opponentsname & ":" & opponentsscore
  1192. End If
  1193. Timer4.Enabled = False
  1194. End Sub
  1195. Public Sub x_Click() 'handles menu item X whos turn first
  1196. If GameUnderway = True Then
  1197. MsgBox "You cannot chang this option while a game is in play", vbOKOnly, "Tic Tac Oops"
  1198. Exit Sub
  1199. End If
  1200. If x.Checked = True Then
  1201.     sw = True
  1202.     Exit Sub
  1203.     x.Checked = True
  1204.     o.Checked = False
  1205.     sw = True
  1206. End If
  1207. If multiplayermode = True Then
  1208. 'Sends who goes first message.
  1209.   Dim dpmsg As DirectPlayMessage
  1210. Set dpmsg = dxplay.CreateMessage
  1211.         Call dpmsg.WriteLong(MSG_XORO)
  1212.         Call dpmsg.WriteByte(1)
  1213.         Call dxplay.Send(MyPlayer, DPID_ALLPLAYERS, DPSEND_GUARANTEED, _
  1214.                 dpmsg)
  1215. End If
  1216. Debug.Print "menu X or O clicked sw is " & sw
  1217. End Sub
  1218.